<?php

namespace app\common\model;

use think\Model;
use app\common\traits\model\TraitModel;

class CapitalDetails extends Model
{
	use TraitModel;

    protected $autoWriteTimestamp = 'datetime';
    protected $createTime         = 'created_at';
    protected $updateTime         = 'updated_at';
    protected $table              = 'capital_details';

    public function users()
    {
        return $this->belongsTo('Users','user_id');
    }

    public function camps()
    {
        return $this->belongsTo('Camps','camp_id');
    }

    public function getIntergralDetailLists($query = array(), $order = 'updated_at desc')
    {
        return $this->getDetailLists(array_merge($query, ['types' => 'integral']), $order);
    }

    public function getIncomeIntergralDetailLists($query = array(), $order = 'updated_at desc')
    {
        return $this->getDetailLists(array_merge($query, ['types' => 'integral', 'amount' =>['>',0]]), $order);
    }

    public function getSpendIntergralDetailLists($query = array(), $order = 'updated_at desc')
    {
        return $this->getDetailLists(array_merge($query, ['types' => 'integral', 'amount' =>['<',0]]), $order);
    }

    public function getDetailLists($query = array(), $order = 'updated_at desc')
    {
        return $this->getInfoList($query, $order);
    }

    // public function getIncomeCashLists($query = array(), $order = 'updated_at desc')
    // {
    //     return $this->getInfoList(array_merge($query, ['user_id' => self::getLoginUserInfo('id'), 'type' => '提现']));
    // }

    // public function getSpendCashLists($query = array(), $order = 'updated_at desc')
    // {
    //     return $this->getInfoList(array_merge($query, ['user_id' => self::getLoginUserInfo('id'), 'type' => '消费']));
    // }

    public function getBlanceDetailLists($query = array(), $order = 'updated_at desc')
    {
        return $this->getDetailLists(array_merge($query, ['types' => 'blance']), $order);
    }

    public function getIncomeBlanceDetailLists($query = array(), $order = 'updated_at desc')
    {
        return $this->getDetailLists(array_merge($query, ['types' => 'blance', 'amount' =>['>',0]]), $order);
    }

    public function getSpendBlanceDetailLists($query = array(), $order = 'updated_at desc')
    {
        return $this->getDetailLists(array_merge($query, ['types' => 'blance', 'amount' =>['<',0]]), $order);
    }






}
